
import React from 'react';
import './Nav.css'
import { FormPreviousLink } from 'grommet-icons';
import { back } from '../../utils/utils'
export default class Nav extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      content: this.props.content ?? "页面",
      isindex: this.props.isindex ?? false
    }
  }

  toBack = () => {
    if (window.socket) {
      window.socket.sendMessage({
        code: "2",
        type: null,
        receiverId: null,
        senderId: null,
        message: null,
        date: null,
        sendFalg: null
      })
    }

    back(window.history, 0.1);
  };

  render () {
    return (
      <div className='nav-local'>
        <div className='nav-black-zindex'></div>
        <div className='nav-black'>
          <div className={this.state.isindex ? 'nav-left' : 'nav-left-active'} onClick={this.toBack}>
            {
              !this.state.isindex && <FormPreviousLink className='nav-back' />
            }
          </div>
          <div className='nav-content'>{this.state.content}</div>
          <div className='nav-right'></div>
        </div>
      </div>
    );
  }
}
